﻿@using DirectSell.Model.ManagerNotice
@model Notices
@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/Manager/Views/Shared/ManagerLayout.cshtml";
}
<title>公告编辑</title>
<article class="page-container">

    <form class="form form-horizontal" id="form1">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章标题：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Title" placeholder="请输入文章标题" required id="Title" name="Title">
            </div>
        </div>

        <div class="row cl" style="display:none">
            <label class="form-label col-xs-4 col-sm-2">排序值：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Id" placeholder="排序" id="Id" name="Id">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">排序值：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Sort" placeholder="排序" id="Sort" name="Sort">
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">文章作者：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Author" placeholder="作者" id="Author" name="Author">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">文章内容：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <script id="editor"name="Ncontent" type="text/plain" style="width:100%;height:400px;">
                </script>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存并提交</button>
                @*<button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
                    <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>*@
            </div>
        </div>
    </form>
</article>

<!--请在下方写此页面业务相关的脚本-->
<script src="~/DirectSellJs/manager/lib/ueditor/ueditor.config.js"></script>
<script src="~/DirectSellJs/manager/lib/ueditor/ueditor.all.min.js"></script>
<script src="~/DirectSellJs/manager/lib/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
$(function(){
    var ue = UE.getEditor('editor');
    debugger;
    var content ='@Html.Raw(Model.Ncontent)';
    
        //判断ueditor 编辑器是否创建成功
        ue.addListener("ready", function () {
        // editor准备好之后才可以使用
        ue.setContent(content);
        });
  
});
$('#form1').on('submit', function () {
    formPost()
    event.preventDefault() //阻止form表单默认提交
})
function formPost() {
    layer.confirm('确定要修改本条公告吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        //加载层
        var index = layer.load(1, {
            shade: [0.1, '#fff']
        });
        $.ajax({
            type: "post",
            url: "/Manager/Notice/Update",
            data: $('#form1').serialize(),
        }).success(function (message) {
            layer.msg('修改成功', { icon: 1 });

        }).fail(function (err) {
            console.log(err);
            layer.msg('系统错误,请稍后重试!', { icon: 2 });
        })
        layer.closeAll();//关闭加载层
    });
}

</script>